@extends('admin.master')

@section('top')
<div class="top-breadcrumb pull-left">{!! Breadcrumbs::render('customer') !!}</div>
@endsection

@section('content')
<div class="section-search mb10">
{!! Form::model($where, ['method'=>'get', 'class'=>'form-inline']) !!}
	<div class="form-group">
		{!! Form::text('word', null, ['class'=>'form-control len', 'placeholder'=>'客户名称或域名']) !!}
	</div>
	<div class="form-group">
		<label class="control-label">业务员：</label>
		{!! Form::select('saler_id', $salers, null, ['class'=>'form-control autosize']) !!}
	</div>
	<button type="submit" class="btn btn-default">查询</button>
{!! Form::close() !!}
</div>
<div class="gridSection">
{!! Form::open(['url'=>'admin/user']) !!}
	<table class="table table-hover table-list" id="customer-list">
		<thead>
			<tr>
				<th width="65" class="text-center">ID</th>
				<th>客户名称</th>
				<th class="text-center">订单数量</th>
				<th>域名</th>
				<th>联系人</th>
				<th>电话</th>
				<th>区域</th>
				<th>部门</th>
				<th>业务员</th>
				<th>地区</th>
				<th>详细地址</th>
				<th>座机</th>
				<th class="text-right">操作</th>
			</tr>
		</thead>
		@if (!$data->isEmpty())
		<tbody>
			@foreach ($data as $value)
				<tr data-id="{{ $value->id }}">
					<td class="text-center">{{ $value->id }}</td>
					<td>
						<a href="{{ url('admin/customer/'.$value->id) }}">{{ $value->name }}</a>
						@if ($value->vip == 1)
							<span class="label label-warning">VIP</span>
						@endif
					</td>
					<td class="text-center"><span class="text-success">{{ $value->order->count() }}</span></td>
					<td><a href="http://{{ $value->domain }}" target="_blank">{{ $value->domain }}</a></td>
					<td>{{ $value->contact_people }}</td>
					<td>{{ $value->phone }}</td>
					<td>{{ $value->saler->region->name or '---' }}</td>
					<td>{{ $value->saler->department->name or '---' }}</td>
					<td><span class="text-success">{{ $value->saler->name }}</span></td>
					<td>{{ $value->city->implode(' ') }}</td>
					<td>{{ $value->detail_address }}</td>
					<td>{{ $value->tel }}</td>
					<td class="text-right">
						<div class="toolbar">
							<a href="{{ route('admin.customer-note.index', ['cid'=>$value->id]) }}" class="btn-link">笔记</a>
							<span class="text-explode ">|</span>
							<a href="{{ route('admin.customer.edit', $value['id']) }}" class="btn-link">修改</a>
						</div>
					</td>
				</tr>
			@endforeach
		</tbody>
		@endif
	</table>
	@if (!$data->isEmpty())
	<table class="table table-footer">
		<tfoot>
			<tr>
				<td>
					<div class="pagination-box">
						<div class="pull-right">
							<div class="pagination-info">共有{{ $data->total() }}条， 每页显示：20条</div>
							{!! $data->appends(request()->except('page'))->render() !!}
						</div>
					</div>				
				</td>
			</tr>
		</tfoot>
	</table>
	@else
	<div class="simple-none-data text-center">
		<i class="fa fa-exclamation-circle text-size-20 text-muted" style="vertical-align: middle"></i> 
		<span class="text-size-14 inline-block ml5">没有查询到符合条件的记录</span>
	</div>
	@endif
{!! Form::close() !!}
</div>
@endsection

@section('foot')
<script src="{{ url('js/bootstrap.min.js') }}"></script>
@endsection